import java.util.ArrayList;
import java.util.List;
public class Student {
    private String id;
    private String name;
    private String gender;
    private List<Course> selectedCourses = new ArrayList<>();
    public Student(String id, String name, String gender) {
        this.id = id;
        this.name = name;
        this.gender = gender;
    }
    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println(name + " 选修了 " + course.getCourseName() + " 课程");
    }
    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println(name + " 退选了 " + course.getCourseName() + " 课程");
        } else {
            System.out.println(name + " 未选修 " + course.getCourseName() + " 课程，无法退选");
        }
    }
    public List<Course> getSelectedCourses() {
        return selectedCourses;
    }
    public String getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public String getGender() {
        return gender;
    }
}

